export function t(myChart, text, name, data) {
  return myChart.setOption({
    backgroundColor: "#2c343c",
    title: {
      text: text,
      left: "center",
      top: 20,
      textStyle: {
        color: "#ccc"
      }
    },
    tooltip: {
      trigger: "item",
      formatter: "{a}<br/>{b}: {c} ({d}%)"
    },
    // visualMap: {
    //     show: false,
    //     min: 3000,
    //     max: 10000,
    //     inRange: {
    //         colorLightness: [0, 1]
    //     }
    // },
    series: [
      {
        name: name,
        type: "pie",
        radius: "55%",
        data: data,
        label: {
          normal: {
            textStyle: {
              color: "rgba(255,255,255,0.3)"
            }
          }
        },
        labelLine: {
          normal: {
            lineStyle: {
              color: "rbga(255,255,255,0.3)"
            },
            smooth: 0.2,
            length: 10,
            length2: 20
          }
        },
        itemStyle: {
          normal: {
            color: '#c23531',
            shadowBlur: 200,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        },

        animationType: 'scale',
        animationEasing: 'elasticOut',
        animationDelay: function () {
          return Math.random() * 200;
        }
      }
    ]
  });
}

const colors = ['#5793f3', '#d14a61', '#675bba'];

export function z(myChart, text, xAxis1, xAxis2, series, legend) {
  return myChart.setOption({
    color: colors,
    title: { text: text, left: 'center' },
    tooltip: { trigger: 'none', axisPointer: {type: 'cross'} },
    legend: {
      data: legend,
      selectedMode: 'single',
      right: '20%'

    },
    grid: {
      top: 70,
      bottom: 50
    },
    toolbox: {
      feature: {
        saveAsImage: {}
      }
    },
    xAxis: [
      {
        type: 'category',
        axisTick: {
          alignWithLabel: true
        },
        axisLine: {
          onZero: false,
          lineStyle: {
            color: colors[1]
          }
        },
        axisPointer: {
          label: {
            formatter: function (params) {
              return params.value
                + (params.seriesData.length ? '：' + params.seriesData[0].data : '');
            }
          }
        },
        data: xAxis2
      },
      {
        type: 'category',
        axisLine: {
          onZero: false,
          lineStyle: {
            color: colors[0]
          }
        },
        axisPointer: {
          label: {
            formatter: function (params) {
              return params.value
                + (params.seriesData.length ? '：' + params.seriesData[0].data : '');
            }
          }
        },
        data: xAxis1
      }
    ],

    yAxis: {
      type: 'value'
    },
    series: series,
  })
}

export function y(myChart, text, yAxis,series) {
  return myChart.setOption({
    title: {
      text: text,
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'shadow'
      }
    },
    legend: {
      data: ['2018', '2019']
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: {
      type: 'value',
      boundaryGap: [0, 0.01]
    },
    yAxis: {
      type: 'category',
      data: yAxis
    },
    series: series
  })
}